#include "tempthread.h"

tempthread::tempthread(QObject *parent) : QObject(parent)
{
    socket = new QTcpSocket;
    connect(socket,&QTcpSocket::readyRead,this,[this](){
        QByteArray data = socket->readAll();
        emit tempDataReceived(QString(data));
    });
}

tempthread::~tempthread()
{
    socket->disconnectFromHost();//与主机断开连接
    socket->deleteLater();      //确保主机被删除
}

void tempthread::run()
{
    socket->connectToHost("192.168.37.56",8886);
    if(!socket->waitForConnected(3000)){
        qDebug() << "连接失败<Get temp Port:8886 >" << socket->errorString();
        return;
    }
}
